/*
 *  Copyright 2009 Lucas Nazário dos Santos
 *  
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  
 *      http://www.apache.org/licenses/LICENSE-2.0
 *  
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package net.sourceforge.retriever.sample;

import java.net.MalformedURLException;
import java.net.URL;

import net.sourceforge.retriever.Retriever;
import net.sourceforge.retriever.feedback.ConsoleFeedback;
import net.sourceforge.retriever.fetcher.Fetcher;

/*
 * This sample shows how to define the maximum amount of time that a connection
 * to some resource can live. This is useful to interrupt dead connections, or
 * to exclude crawling resources that are too big in size.
 */
public class DefiningTheMaximumAmountOfTimeConnectionsCanLive {


	public static void main(String[] args) throws MalformedURLException {

		// Creates the crawler
		final Retriever crawler = new Retriever(new ConsoleFeedback());

		// Adds a seed
		crawler.addSeed(new URL("http://sourceforge.net/"));

		// Informs the crawler that all resources must be crawled in less than
		// one millisecond. As you can guess, no page will be collected because
		// one millisecond is not enough time for the task.
		Fetcher.setFetchTimeout(1);

		crawler.start();
	}
}